<!DOCTYPE html>
<html lang="en">

<%@ page contentType="text/html; charset=utf-8"%>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Amaze UI Admin index Examples</title>
    <meta name="description" content="这是一个 index 页面">
    <meta name="keywords" content="index">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="assets/i/favicon.png">
    <link rel="apple-touch-icon-precomposed" href="assets/i/app-icon72x72@2x.png">
    <meta name="apple-mobile-web-app-title" content="Amaze UI" />
    <script src="/assets/js/echarts.min.js"></script>
    <link rel="stylesheet" href="/assets/css/amazeui.min.css" />
    <link rel="stylesheet" href="/assets/css/amazeui.datatables.min.css" />
    <link rel="stylesheet" href="/assets/css/app.css">
    <script src="/assets/js/jquery.min.js"></script>

</head>

<body data-type="index">
<div class="am-g tpl-g">
    <!-- 头部 -->
    <jsp:include page="common/atmHead.jsp"></jsp:include>
    <!-- 风格切换 -->

    <!-- 侧边导航栏 -->
    <jsp:include page="common/atmLeft.jsp"></jsp:include>


    <!-- 内容区域 -->
    <div class="tpl-content-wrapper">

        <div class="row-content am-cf">
            <div class="row  am-cf">

                <div class="row">

                    <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
                        <div class="widget am-cf">
                            <div class="widget-head am-cf">
                                <div class="widget-title am-fl">消息列表</div>
                                <div class="widget-function am-fr">
                                    <a href="javascript:;" class="am-icon-cog"></a>
                                </div>
                            </div>
                            <div class="widget-body am-fr">

                                <form id="flowForm" action="/flow/downLoadFlow.do" method="post" class="am-form tpl-form-line-form">

                                </form>



                                <div class="widget am-cf">
                                    <div class="widget-head am-cf">
                                        <div class="widget-title am-fl"></div>
                                        <div class="widget-function am-fr">

                                        </div>
                                    </div>
                                    <div class="widget-body  widget-body-lg am-fr">

                                        <table width="100%" class="am-table am-table-compact am-table-striped tpl-table-black " id="example-r">
                                            <thead>
                                            <tr>
                                                <th>ID</th>
                                                <th>内容</th>
                                                <th>类型</th>
                                                <th>状态</th>
                                                <th>时间</th>

                                            </tr>
                                            </thead>
                                            <tbody id="messages">

                                            <!-- more data -->
                                            </tbody>
                                        </table>

                                        <button onclick="first()">首页</button>
                                        <button onclick="pre()">上一页</button>
                                        <button onclick="next()">下一页</button>
                                        <button onclick="last()">尾页</button>

                                        <div id="pageInfo"></div>

                                    </div>
                                </div>



                            </div>

                        </div>
                    </div>
                </div>





            </div>




        </div>



    </div>
</div>
</div>
</div>


<script>

    $('#myMessage').addClass('active');

    var currnetPage = 1;
    var totalPage = 1;

    function first() {
        currnetPage = 1;
        queryMessage();
    }
    function last() {
        currnetPage = totalPage;
        queryMessage();
    }

    function next() {
        if (currnetPage == totalPage) {
            return;
        }

        currnetPage ++;
        queryMessage();
    }

    function pre() {
        if (currnetPage == 1) {
            return;
        }

        currnetPage --;
        queryMessage();
    }


    function queryMessage() {
        dayuanit.ajax('/message/queryMessage.do', {
            currentPage : currnetPage
        }, function (result) {
            var messages = result.data.data;
            var msgHtml = '';
            for (var i=0; i<messages.length;i ++) {
                var msg = messages[i];
                msgHtml += '<tr class="gradeX">\n' +
                    '                                            <td>'+msg.msgId+'</td>\n' +
                    '                                            <td>'+msg.context+'</td>\n' +
                    '                                            <td>'+msg.msgType+'</td>\n' +
                    '                                            <td>'+msg.status+'</td>\n' +
                    '                                            <td>'+msg.createTime+'</td>\n' +
                    '                                        </tr>';
            }

            totalPage = result.data.totalPage;
            $('#pageInfo').html(currnetPage + '/' + totalPage);
            $('#messages').html(msgHtml);
        })
    }

    function downLoadFlow() {
        $('#flowForm').submit();
    }

    queryMessage();
</script>

</body>

</html>